package com.cy.letcode.进制.进制转换;

import cn.hutool.core.map.MapUtil;

public class Solution {


    public static void main(String[] args) {
        int n = -10;
        System.out.println(tenToTwo(n));
        System.out.println(Integer.toBinaryString(n));
    }

    public static String tenToTwo(int n) {
        String result = "";
        while (n != 0) {
            result = ((n & 1) == 1 ? 1 : 0) + result;
            n = n > 0 ? n >> 1 : n >>> 1;
        }
        return result;
    }
}
